<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Class site_model extends CI_Model
 * ----------------------------------------------------------
 * Author:		Michael Lamb
 * Date:		March 2012
 * Version:		0.1
 * 
 * ----------------------------------------------------------
 * Synopsis:
 * ---------
 * Public news model
 * 
 * Grabs a list of news articles from the database
 *
 * Grabs a single news article from the database
 *
 * ----------------------------------------------------------
 * Methods:
 * --------
 * 
 * 
 * ----------------------------------------------------------
 * Planned Changes:
 * ----------------
 * 
 * 
 * ----------------------------------------------------------
 * Version History:
 * ----------------
 * 0.1
 * ---
 * 
 *   
 * ----------------------------------------------------------
 * ##########################################################
 * ----------------------------------------------------------
 */
class News_model extends CI_Model {
	/**
	 * Name: listArticles
	 * Scope: Public
	 * 
	 * @params:
	 * 		$params - array
	 */
	function getAll()
	{
		$this->db->select('article_id', 'title', 'date', 'excerpt');
		$this->db->from('news');
		$this->db->order_by('date', 'desc');
		$query = $this->db->get();
		
		return $query->result();
	}
	
	/**
	 * Name: getPageContent
	 * Scope: Public
	 * 
	 * @params:
	 * 		$page_name - string
	 */
	function getArticle($params)
	{
		extract($params,EXTR_SKIP);
		
		if(isset($article)&&$article!='')
		{
			$this->db->select('title','date', 'article');
			$this->db->from('news');
			$this->db->where('article_id = "'.$article."'");
			$query = $this->db->get();
			
			return $query->result();
		}
		else
		{
			return false;
		}
	}
}
/* End of file site_model.php */
/* Location: ./application/models/site_model.php */